package com.lwc.controller;

import com.lwc.bean.MaterialStock;
import com.lwc.bean.MaterialStockQuery;
import com.lwc.common.bean.PageBean;
import com.lwc.common.bean.ResultBean;
import com.lwc.common.controller.BaseController;
import com.lwc.service.MaterialStockService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api")
@Api(tags = "物料库存")
public class MaterialStockController extends BaseController {

@Autowired
    MaterialStockService materialStockService;


@ApiOperation("筛选查询")
    @PostMapping("/query")
    public ResultBean  query(@RequestBody MaterialStockQuery materialStockQuery){
        PageBean pageBean=materialStockService.query(materialStockQuery);
        return  success("查询成功",pageBean);
    }

    @ApiOperation("导出")
    @PostMapping("/export")
    public  ResultBean export(){
  String url=materialStockService.export();
    return  success("导出成功",url);
    }

    /**
     *
     * 通过订单id查询订单信息
     */
    @ApiOperation("通过订单id查询订单信息")
    @GetMapping("/queryorder")
    public ResultBean  queryorder(int id  ){
        Map map=materialStockService.queryorderBById(id);
        return  success("查询成功",map);
    }

    //在搞一个导入
//加库存


    @ApiOperation("导入")
    @PostMapping("/toread")
    public  ResultBean tolead(@RequestBody  MultipartFile file){
       int rs=materialStockService.tolead(file);
return rs>0?success("导入成功"):fail("导入失败");

    }


}
